package com.spdzen.support.result;

import java.io.Serializable;

/**
 * 用于Service返回与业务代码相关的结果
 * 
 * @author accountwcx@qq.com
 *
 * @param <T>
 */
public class SimpleResult<T> implements Serializable {
	private static final long serialVersionUID = -1602346002635212268L;
	
	private ResultCode code = BaseResultCode.SUCCESS;
	private T data;

	public SimpleResult() {
	}

	public SimpleResult(ResultCode code) {
		this.code = code;
	}

	public SimpleResult(T data) {
		this.data = data;
	}

	public SimpleResult(ResultCode code, T data) {
		this.code = code;
		this.data = data;
	}

	public ResultCode getCode() {
		return code;
	}

	public void setCode(ResultCode code) {
		this.code = code;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public static SimpleResult<Object> instance(ResultCode code) {
		SimpleResult<Object> result = new SimpleResult<Object>();
		result.setCode(code);
		return result;
	}

	public static <T> SimpleResult<T> instance(T data) {
		SimpleResult<T> result = new SimpleResult<T>();
		result.setData(data);
		return result;
	}
}
